package han.cirno.corrupt.data.instances

import han.cirno.corrupt.data.UserDataFileAnn
import han.cirno.corrupt.data.UserDataInstance
import han.cirno.corrupt.components.school.impl.SerializableCookies
import java.io.Serializable
import kotlin.reflect.KClass
import kotlin.reflect.cast

@UserDataFileAnn("corruptSchoolData.dat")
class UserSchoolData:Serializable {
    companion object {
        @UserDataInstance
        var instance:UserSchoolData=UserSchoolData()
    }

    enum class School {
        None, FAFU, MJU, FJUT
    }

    private val dataMap=HashMap<String,Serializable?>()
    var cookies= SerializableCookies()
    fun <T:Any> get(name:String,kClass:KClass<T>):T? {
        val value=dataMap[name] ?: return null
        return kClass.cast(value)
    }

    fun put(name:String,value:Serializable?) {
        dataMap[name]=value
    }
}